<?php
/**
 * remove message(post)
 */
require_once('rb.php');
R::setup('mysql:host=ftp.giemiebier.nl:3306;dbname=personify', 'school', 'admin123');

$return = array();

if ($pagetree[2] != "" && isset($pagetree[2])){
    $id = $pagetree[2];
}else{
    $id = "";
}

$message = "";
if (isset($_POST['postid']) && $_POST['postid'] != "") {
    deleteMessage($id);
    $return['removemessage'] = true;
}
else{
    $return['removemessage'] = false;
    $return['error'] = "It's not possible to delete this way.";
}

echo json_encode($return);

function deleteMessage($id){
    $post = R::load('posts',$_POST['postid']);
    R::trash($post);
}
?>

